﻿using System;
using System.Windows;
using System.Windows.Media.Imaging;
using MessageBoxImage = HospitalSelfServiceMachine.Bean.MessageBoxImage;

namespace HospitalSelfServiceMachine.Views
{
    /// <summary>
    /// HSMessageBox.xaml 的交互逻辑
    /// </summary>
    public partial class HSMessageBox : Window
    {

        private string _message;

        public HSMessageBox(string message)
        {
            InitializeComponent();
            _message = message;
            tb_info.Text = _message;    
            loadMsgImage(MessageBoxImage.Information);
            loadButton(MessageBoxButton.OK);
        }



        public HSMessageBox(string message, MessageBoxImage imageType, MessageBoxButton messageBoxButton)
        {
            InitializeComponent();
            _message = message;
            tb_info.Text = _message;
            loadMsgImage(imageType);
            loadButton(messageBoxButton);
        }


        private void loadMsgImage(MessageBoxImage messageBoxImage)
        {
            switch(messageBoxImage)
            {
                case MessageBoxImage.Information:
                    {
                        image_tip.Source = new BitmapImage(new Uri(@"/Images/tip_info.png",UriKind.Relative));
                        break;
                    }
                    default:
                    {
                        image_tip.Source = new BitmapImage(new Uri(@"Images\\tip_info.png"));
                        break;
                    }
            }
        }

        private void loadButton(MessageBoxButton messageBoxButton)
        {
            switch(messageBoxButton)
            {
                case MessageBoxButton.OK:
                    {
                        btn_ok.Visibility = Visibility.Collapsed;
                        btn_cancel.Visibility = Visibility.Visible;
                        break;
                    }
                case MessageBoxButton.OKCancel:
                    {
                        btn_ok.Visibility = Visibility.Visible;
                        btn_cancel.Visibility = Visibility.Visible;
                        break;
                    }
                case MessageBoxButton.YesNo:
                    {
                        btn_ok.Visibility = Visibility.Visible;
                        btn_cancel.Visibility = Visibility.Visible;
                        break;
                    }
                default:
                    {
                        btn_ok.Visibility = Visibility.Visible;
                        btn_cancel.Visibility = Visibility.Visible;
                        break;
                    }
            }
        }

        private void btn_ok_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
        }

        private void btn_cancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }
    }
}
